#!/bin/bash

if [ $# -lt 1 ];
then
    echo "$0 list"
    echo "$0 info"
    echo "$0 login"
    echo "$0 logout"
    echo "$0 start <keyword> <price>"
    echo "$0 data <offset> <limit>"
    echo "$0 stop"
    echo "$0 clear"
    exit
fi

USERID='admin'
PASSWD='admin'
URL='http://127.0.0.1:9000'

case "$1" in
    info|login|logout|stop|clear)
        curl "$URL/$1?uid=$USERID&pwd=$PASSWD"
        ;;
    
    list)
        curl "$URL/$1"
        ;;
    
    start)
        if [ $# -eq 3 ];
        then
            curl "$URL/$1?uid=$USERID&pwd=$PASSWD&keyword=$2&price=$3"
        fi
        ;;
    
    data)
        if [ $# -eq 3 ];
        then
            curl "$URL/$1?uid=$USERID&pwd=$PASSWD&offset=$2&limit=$3"
        fi
        ;;
esac

echo

